package com.travel.service;

import com.travel.dao.TravelDao;
import com.travel.entity.Travel;
import com.travel.exception.BigException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TravelService {

    @Autowired
    TravelDao travelDao;

    public List<Travel> getAll(){
        return travelDao.getAll();
    }

    public Travel getOne(Integer id){
        return travelDao.getOne(id);
    }

    public void add(Travel travel){
//        if(travel.getArea().length()>10){
//            throw new RuntimeException("地区不符合要求");
//        }
//        if(travel.getArea().indexOf("老板") != -1){
//            throw new BigException("输入了非法词汇");
//        }
        travelDao.add(travel);
    }

    public void delete(Integer id){
        travelDao.delete(id);
    }
}
